package common.utils;

import android.content.SharedPreferences;

/**
 * Created by yinzhiqun on 2015/8/25.
 */
public class BufferedSharedPreferences {
    private SharedPreferences sp;
    public BufferedSharedPreferences(SharedPreferences sp){
        this.sp = sp;
    }

    public void saveString(String key, String value) {
        sp.edit().putString(key, value).apply();
    }

    public String getString(String key,String defValue){
        return sp.getString(key, defValue);
    }

    public void saveInt(String key, int value){
        sp.edit().putInt(key, value).apply();
    }

    public int getInt(String key,int defValue){
        return sp.getInt(key, defValue);
    }

    public void saveBoolean(String key, boolean value){
        sp.edit().putBoolean(key, value).apply();
    }

    public boolean getBoolean(String key,boolean defValue){
        return sp.getBoolean(key, defValue);
    }

    public void remove(String key){
        sp.edit().remove(key).apply();
    }

    public void clear(){
        sp.edit().clear().apply();
    }

}
